package com.zfast.yugioh.antlr4.effect.impl;

import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.TokenFactory;
import org.antlr.v4.runtime.TokenSource;
import org.antlr.v4.runtime.misc.Pair;

/**
 * @author zgn
 * @Description: EffectFactory
 * @date 2022/7/19 0019
 */
public class EffectFactory implements TokenFactory<EffectToken> {
    CharStream input;

    public EffectFactory(CharStream inputStream) {
        this.input=inputStream;
    }

    @Override
    public EffectToken create(Pair<TokenSource, CharStream> source, int type, String text
            , int channel , int start, int stop,
              int line, int charPositionInLine) {
        EffectToken effectToken=new EffectToken(source,type,channel,start,stop);
        effectToken.setLine(line);
        effectToken.setCharPositionInLine(charPositionInLine);
        effectToken.srcName=input.getSourceName();
        return effectToken;
    }

    @Override
    public EffectToken create(int type, String text) {
        return new EffectToken(type,text);
    }
}
